package com.example.demo.service;

import com.example.demo.POJO.DemoEntity;
import com.example.demo.dao.DemoRepository;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.math.BigDecimal;
import java.util.Calendar;
import java.util.List;

@Service
public class DemoService {

    private final Logger logger = LoggerFactory.getLogger(DemoService.class);

    @Autowired
    private DemoRepository demoRepository;

    public List<DemoEntity> doSomething(){
        logger.debug("debug...");
        logger.info("info...");
        logger.warn("warn...");
        logger.error("error...");
        DemoEntity demo =new DemoEntity();
        demo.setDesc("test log");
        demo.setValue(new BigDecimal(666));
        demo.setType(0);
        demo.setCreateTime(Calendar.getInstance().getTime());
        demo.setUpdateTime(Calendar.getInstance().getTime());
        demoRepository.save(demo);
        return demoRepository.findAll();
    }
}
